package com.example.demo.controller;

import com.example.demo.common.Result;
import com.example.demo.dto.RouteAddDTO;
import com.example.demo.dto.RouteGetDTO;
import com.example.demo.service.RouteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/v1/route")
public class RouteController {
    @Autowired
    private RouteService routeService;
    @PostMapping
    public Result addRoute(@RequestBody RouteAddDTO routeAddDTO) {
//        System.out.println(routeAddDTO.toString());
        return routeService.addRoute(routeAddDTO);
    }

    @GetMapping
    public Result getRoutes(RouteGetDTO routeGetDTO) {
        return routeService.getRoutes(routeGetDTO);
    }

    @GetMapping("/getAllRoutes")
    public Result getAllRoutes() {
        return routeService.getAllRoutes();
    }

    @GetMapping("/getStopsByCheciId")
    public Result getStopsByCheciId(Integer checiId){
        return routeService.getStopsByCheciId(checiId);
    }

    @PutMapping
    public Result updateRoute(@RequestBody RouteAddDTO routeAddDTO) {
        return routeService.updateRoute(routeAddDTO);
    }

}
